package com.ateam.biz.impl;

import java.util.List;

import com.ateam.biz.ApplicationsBiz;
import com.ateam.dao.ApplicationsDao;
import com.ateam.pojo.Applications;

/** 
* @author WuYuan
* 
*/
public class ApplicationsBizImpl implements ApplicationsBiz {
	private ApplicationsDao applicationsDao;
	
	public ApplicationsDao getApplicationsDao() {
		return applicationsDao;
	}

	public void setApplicationsDao(ApplicationsDao applicationsDao) {
		this.applicationsDao = applicationsDao;
	}

	@Override
	public int addApplication(Applications application, int applicant, int approver) {
		try {
			applicationsDao.addApplication(application);
			return applicationsDao.addUserApplication(applicant, approver, application.getApplicationid());
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return 0;
		
	}

	@Override
	public int updateThroughApplication(int applicationid) {
		try {
			return applicationsDao.updateApplication(applicationid);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return 0;
	}

	@Override
	public List<Applications> getApplicationsByApprover(int approver) {
		try {
			return applicationsDao.getApplicationsByApprover(approver);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public List<Applications> getApplicationsByApplicant(int applicant) {
		try {
			return applicationsDao.getApplicationsByApplicant(applicant);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

}
